<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加课程</title>
<link rel="stylesheet" href="../../easyui/themes/default/easyui.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="../../easyui/themes/icon.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/main.css" type="text/css"
	media="screen" />
<link rel="stylesheet" type="text/css" href="../../css/Tooltip.css" />
<script src="../../myjs/schedule/scheduleManager.js"></script>
<script src="../../easyui/jquery-1.4.4.min.js"></script>
<script src="../../easyui/jquery.easyui.min.js"></script>
<!-- mytab -->
<script src="../../myjs/myTab.js"></script>
<!-- sys -->
<script src="../../myjs/sys.js"></script>
<script src="../../myjs/DatePicker/WdatePicker.js"></script>
<script src="../../easyui/easyMask.js"></script>
<script src="../../easyui/easyUI.js"></script>
<script src="../../easyui/easyLayer.js"></script>
<style type="text/css">
.right {
	float: middle;
	width: 500px;
}

.right table {
	background: #E0ECFF;
	width: 100%;
}

.right td {
	background: #fafafa;
	text-align: center;
	font-weight: bold;
	padding: 2px;
}

.right td.drop {
	background: #fafafa;
	width: 300px;
}

.right td.title {
	background: #7BA0CD;
	color: white;
	font-weight: bold;
}

.right td.courseno {
	background: #E0ECFF;
}
</style>
</head>
<body>
<script>

	 var greyLayer ;
	 var grid;
	 $(function(){
		 //课程表grid
	 grid=$('#tt2').datagrid({ 
		 pagination:false,
		 singleSelect:true,
		 fit:true,//表格自动填充
		 loadMsg:'正在努力为您加载，请稍作等待…',//加载信息
		 toolbar:[{
		 text:'排课',
		 iconCls:'icon-add',
		 handler:'newSchedule'
		 },'-',{
		 text:'修改排课',
		 iconCls:'icon-edit',
		 handler:'editSchedule'
		
		 },'-',{
		 text:'删除排课',
		 iconCls:'icon-remove',
		 handler:'delSchedule'
		 }]});
	 //课程grid
	 grid2 = $('#tt').datagrid({
	 //url:'/pxglxt/schedule/getSchedules',
	 url:'/pxglxt/course/getCourses',
	 pagination:true,
	 singleSelect:true,
	 fit:true,//表格自动填充
	 loadMsg:'正在努力为您加载，请稍作等待…',//加载信息
	 onClickRow:function(rowIndex,rowData){
		//根据选择的课程，加载已排的课程表信息
		var courseId = rowData.id;
		//加载课表grid
		try{
			 grid=$('#tt2').datagrid({
				 url:'/pxglxt/schedule/getScheduleByCourseId?courseId='+courseId});
			 //清空
				$('#course_id').attr('value', '');
			 	$('#course_name').attr('value', '');
				$('#course_hours').attr('value', '');
				$('#course_times').attr('value', '');
		}catch(e){
			sys_alert('系统异常', "课程ID:"+courseId+",可能课程信息已经被删除！", 'error');
		}
	 }
		 
	 });
	 //初始化pagination工具开始
	 var pagetool = $('#tt').datagrid('getPager');
	 pagetool.pagination({				
	 beforePageText:'第',
	 afterPageText:'页，共{pages}页',
	 displayMsg:'显示从 {from} 到  {to} , 总记录 {total} '});
	 
	 $('body').layout();
	 $('#btn-save,#btn-cancel').linkbutton();

	 win = $('#user-window').window({
	 collapsible:false,
	 minimizable:false, 
	 maximizable:true, 
	 closable:true,
	 onClose:function(){greyLayer.close();},
	 closed:true
	 });
	 form = win.find('form');
	 greyLayer = new easyMask(null,'100%','100%',100,'#000',8,true);
//选择教师
	 $('#tea_id').combobox({
		    url:'/pxglxt/course/getTeachers',
		    valueField:'id',
		    textField:'tea_real_name',
		    onChange:function(n,o){
		 		if(n!='') validTeacher(n);
		    }
		});
//选择教室
	 $('#room_id').combobox({
		    url:'/pxglxt/classroom/getClassroomForComb',
		    valueField:'id',
		    textField:'room_number',
		    onChange:function(n,o){
		    if(n!='') validClassroom(n);
		    }
		});
	 });
</script>

<div region="north" border="false"
	style="border-bottom: 1px solid #ddd; height: 32px; padding: 2px 5px; background: #fafafa;">
<div style="float: left;">请输入课程的名称：<input type="text"
	name="sear_course" id="sear_course" widht="200px"> <a
	href="javascript:void(0)" class="easyui-linkbutton" plain="true"
	icon="icon-search" onclick="searchCourse();">查询</a></div>
</div>
<div region="west" split="true" title="课程列表"
	style="width: 500px; padding: 2px;" icon="icon-course">
<table id="tt">
	<thead>
		<tr>
			<th field="course_name" width="100%">课程名称</th>
			<th field="coursetype_key" width="100%">课程类别</th>
			<th field="suitgrade_key" width="100%">适合年级</th>
			<th field="tea_name" width="100%">任课教师</th>
			<th field="labour_name" width="100%">班主任</th>
			<th field="classes_key" width="100%">班级类型</th>
			<th field="course_stu_nums" width="100%">预招人数</th>
			<th field="course_stu_counts" width="100%">实际人数</th>
			<th field="course_begin" width="100%">开课时间</th>
			<th field="course_end" width="100%">结束时间</th>
			<th field="course_hours" width="100%">总课时</th>
			<th field="course_times" width="100%">课程节数</th>
			<th field="coursestatus_key" width="100%">课程状态</th>
			<th field="course_desc" width="100%">课程备注</th>
		</tr>
	</thead>
</table>
</div>

<div region="center" title="课程课表" style="padding: 2px;"
	icon="icon-schedule">
<table id="tt2">
	<thead>
		<tr>
			<th field="course_name" width="100%">课程名称</th>
			<th field="teacher_name" width="100%">教师姓名</th>
			<th field="room_name" width="100%">教室</th>
			<th field="course_progress" width="100%">课时进度</th>
			<th field="schedule_date" width="100%">上课日期</th>
			<th field="schedule_begin" width="100%">上课时间</th>
			<th field="schedule_end" width="100%">下课时间</th>
			<th field="creator_name" width="100%">制表人</th>
			<th field="schedule_time" width="100%">制单日期</th>
		</tr>
	</thead>
</table>
</div>
<div id="user-window" title="课程安排" style="width: 530px; height: 500px;"
	icon="icon-scheduledetail">
<div style="padding: 10px 10px 10px 10px;">
<form method="post">
<div class="right">
<table>
	<tr>
		<td colspan="2" class="title">教务排课</td>
	</tr>
	<tr>
		<td class="time">课程名称</td>
		<td class="drop"><input class="easyui-validatebox" type="text"
			name="course_name" id="course_name" required="true" readonly=true></input><input
			type="hidden" name="course_id" id="course_id"></input></td>

	</tr>
	<tr>
		<td class="time">总课时</td>
		<td class="drop"><input class="easyui-validatebox" type="text"
			name="course_hours" id="course_hours" required="true" readonly=true></input></td>

	</tr>
	<tr>
		<td class="time">总课程次数</td>
		<td class="drop"><input class="easyui-validatebox" type="text"
			name="course_times" id="course_times" required="true" readonly=true></input></td>

	</tr>
	<tr>
		<td class="time">每次课程时间长度</td>
		<td class="drop"><input class="easyui-validatebox" type="text"
			name="hourspertimes" id="hourspertimes" required="true" readonly=true></input></td>

	</tr>
	<tr>
		<td class="courseno" colspan="2">
		<div name="progress" id="progress"></div>
		<input type="hidden" name="course_progress" id="course_progress"></input></td>
	</tr>
	<tr>
		<td class="time">上课日期</td>
		<td class="drop"><input type="text" class="Wdate" size="32"
			name="schedule_date" id="schedule_date" value="" maxlength="10"
			required="true" onClick="WdatePicker();" onchange="validBeginDate();"></td>

	</tr>
	<tr>
		<td class="time">上课开始时间</td>
		<td class="drop"><input type="text" name="schedule_begin"
			id="schedule_begin" value="" maxlength="130" class="Wdate"
			required="true" onClick="WdatePicker({dateFmt:'HH:mm:ss'})"></td>

	</tr>
	<tr>
		<td class="time">上课结束时间</td>
		<td class="drop"><input type="text" name="schedule_end"
			id="schedule_end" value="" maxlength="130" class="Wdate"
			required="true" onClick="WdatePicker({dateFmt:'HH:mm:ss'})"></td>

	</tr>
	<tr>
		<td class="time">教室</td>
		<td class="drop"><input id="room_id" name="room_id"
			required="true"> <!-- <input class="easyui-combobox" name="room_id"
			url="/pxglxt/classroom/getClassroomForComb" valueField="id"
			textField="room_number" multiple="false" panelHeight="auto"
			required="true"> --></input></td>
	</tr>
	<tr>
		<td class="time">教师</td>
		<td class="drop"><input id="tea_id" name="tea_id" required="true">
		<!-- 
		<input class="easyui-combobox" name="tea_id" id=""
			url="/pxglxt/course/getTeachers" valueField="id"
			textField="tea_real_name" multiple="false" panelHeight="auto"
			style="width: 220px" required="true"> --></input></td>
	</tr>
	<tr>
		<td colspan="2"></td>
	</tr>
	<tr>
		<td class="courseno">制表人</td>
		<td class="drop"><input class="easyui-combobox"
			name="schedule_creator" url="/pxglxt/course/getLabours"
			valueField="id" textField="real_name" multiple="false"
			panelHeight="auto" style="width: 220px" required="true"></input></td>
	</tr>
	<tr>
		<td class="courseno">制表时间</td>
		<td class="drop"><input type="text" name="schedule_time"
			id="schedule_time" value="" maxlength="130" class="Wdate"
			required="true"
			onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly></td>
	</tr>
</table>
</div>
</form>
</div>

<div style="text-align: center; padding: 5px;"><a
	href="javascript:void(0)" onclick="saveSchedule()" id="btn-save"
	icon="icon-save">确定</a> <a href="javascript:void(0)"
	onclick="closeWindow()" id="btn-cancel" icon="icon-cancel">取消</a></div>
</div>

</body>
</html>
